package com.kd.service.jobSeeker.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kd.bean.jobSeeker.Basic_information;
import com.kd.bean.recruiter.Company_msg;
import com.kd.dao.jobSeeker.IBasic_informationDao;
import com.kd.service.jobSeeker.IBasic_informationService;
import com.mysql.fabric.xmlrpc.base.Data;

/**
 * 数据服务层<Basic_informationServiceImpl>
 * @author ZFC
 *
 */
@Service
@Transactional
public class Basic_informationServiceImpl implements IBasic_informationService{

	@Autowired
	private IBasic_informationDao basicdao;
	
	@Override
	public Basic_information basicLogin(Basic_information basic) throws Exception {
		
		return basicdao.basicLogin(basic);
	}

	@Override
	public Boolean basicRegister(Basic_information basic) throws Exception {
		basic.setCreate_time(new Date());//给予求职者创建时间
		return basicdao.basicRegister(basic)>0;
	}

	@Override
	public Basic_information retrievePasswordShowPassword(Basic_information basic) throws Exception {
		
		return basicdao.retrievePasswordShowPassword(basic);
	}

	@Override
	public PageInfo<Basic_information> queryAllBasic_information(Integer pageNum, Integer pageSize) throws Exception {
		PageHelper.startPage(pageNum, pageSize);
		List<Basic_information> list = basicdao.queryAllBasic_information();
		PageInfo<Basic_information> info = new PageInfo<>(list);
		return info;
	}

	@Override
	public Boolean updateBasic_login_state(Integer login_state,Integer basic_id) throws Exception {
		
		return basicdao.updateBasic_login_state(login_state,basic_id)>0;
	}

	@Override
	public Integer queryBasicPersonCount() throws Exception {
		
		return basicdao.queryBasicPersonCount();
	}

	@Override
	public PageInfo<Basic_information> queryByJudge_deliver_resumAndLikeRec_address(Integer pageNum, Integer pageSize,
			Company_msg company) throws Exception {
		String address = "";
		if(company.getCompany_address().length()>2) {
			address=company.getCompany_address().substring(2);
		}else {
			address=company.getCompany_address();
		}
		PageHelper.startPage(pageNum, pageSize);
		List<Basic_information> list = basicdao.queryByJudge_deliver_resumAndLikeRec_address("%"+address+"%");
		PageInfo<Basic_information> info = new PageInfo<>(list);
		return info;
	}

	@Override
	public Basic_information queryByBasic_id(Integer basic_id) throws Exception {
		
		return basicdao.queryByBasic_id(basic_id);
	}

	@Override
	public Boolean updateBasic_information(Basic_information basic_information) throws Exception {
		
		return basicdao.updateBasic_information(basic_information)>0;
	}

	@Override
	public Boolean updateOnline_resumes(Integer res_id, Integer basic_id) throws Exception {
		
		return basicdao.updateOnline_resumes(res_id, basic_id)>0;
	}

	@Override
	public Boolean updateBasic_informationPwd(Basic_information basic_information) throws Exception {
		
		return basicdao.updateBasic_informationPwd(basic_information)>0;
	}

	@Override
	public Boolean updateBasic_informationBasic_job_state(Integer basic_job_state, Integer basic_id) throws Exception {
		
		return basicdao.updateBasic_informationBasic_job_state(basic_job_state, basic_id)>0;
	}

	@Override
	public Integer queryjudge_deliver_resumCount(Integer basic_id) throws Exception {
		// TODO Auto-generated method stub
		
		return basicdao.queryjudge_deliver_resumCounts(basic_id);
	}

	
	@Override
	public Boolean updatejudge_deliver_resumCount(Integer count, Integer basic_id) throws Exception {
		// TODO Auto-generated method stub
		return basicdao.updatejudge_deliver_resumCount(count, basic_id)>0;
	}

}
